<template>
	<div class="header">
		<router-link tag='div' to='/' class="header-abs" v-show='show'>
				<div class="returnicon iconfont">&#xe624;</div>
		</router-link>
		<div class="header-fixed" v-show='!show' :style='opacity'>
				景点详情
				<router-link to='/'>
					<div class="iconfont Back">&#xe624;</div>
				</router-link>
		</div>
	</div>
</template>

<script>
export default {
	name: 'detailHeader',
	data () {
		return {
			show: true,
			opacity: {
				opacity: 0
			}
		}
	},
	methods: {
		clickShow () {
			let top = document.documentElement.scrollTop

			if (top > 50) {
				let opacity = top / 140
				opacity = opacity > 1 ? 1 : opacity
				this.opacity= { opacity }
				this.show = false	
			} else{
				this.show = true
			}
		}
	},
	activated () {
		window.addEventListener('scroll', this.clickShow)
	},
	deactivated () {
		window.removeEventListener('scroll', this.clickShow)
	}

}	
</script>

<style lang="stylus" scoped>
@import '~styles/varibles.styl'
	.header-abs
		position: absolute
		top: .2rem
		left: .2rem
		right: .2rem
		width: .8rem
		height: .8rem
		line-height: .8rem
		text-align: center
		border-radius: .4rem
		background: rgba(0, 0, 0, .8)
		.returnicon
			color: #fff
			font-size: .24rem
	.header-fixed
		z-index: 2
		height: .86rem
		line-height: .86rem
		overflow: hidden
		text-align: center
		color: #fff
		background: $bgColor
		font-szie: .32rem
		position: fixed
		top: 0
		right: 0
		left: 0
		.Back
			width: .64rem
			position: absolute
			top: 0
			left: 0
			text-align: center
			color: #fff	
</style>